<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.lemall.mobile.wap.local.us.dao.us${className?cap_first}Dao">
<#if functions??>
    <#list functions?keys as key>
        <resultMap id="${functions[key].className}ResultMap" type="com.lemall.mobile.wap.local.us.dto.${functions[key].className}" >
            <#list functions[key].select?split(",") as attr>
                <#if tableMap[functions[key].from]??>
                <result column="${attr}" property="${attr}" jdbcType="${tableMap[functions[key].from][attr].jdbcTypeName}" />
                <#else>
                <result column="${attr}" property="${attr}" jdbcType="VARCHAR" />
                </#if>
            </#list>
        </resultMap>
    </#list>
    <#list functions?keys as key>
        <select id="${key}"  parameterType="java.util.Map" resultType="${functions[key].className}ResultMap">
            SELECT ${functions[key].select!}
            From ${functions[key].from}
            <#if functions[key].where??>
                where
                <#list functions[key].where?keys as w>
                    <#if w_index ==0>
                    ${w} = ${functions[key].where[w]}
                    <#else>
                        and ${w} = ${functions[key].where[w]}
                    </#if>
                </#list>
            </#if>
            <#if functions[key].orderBy??>
                order by
                <#list functions[key].orderBy?keys as w>
                    <#if w_index ==0>
                    ${w} ${functions[key].orderBy[w]} <#else> ,${w} ${functions[key].orderBy[w]}
                    </#if>
                </#list>
            </#if>
            <#if functions[key].limit??>
                limit ${functions[key].limit}
            </#if>
        </select>
    </#list>
</#if>
</mapper>
